from aiogram import F
from aiogram_dialog import Window
from aiogram_dialog.widgets.kbd import Back, Button, Group

from src.presentation.tg_bot.dialogs.getters.orders import extend_summary_getter
from src.presentation.tg_bot.dialogs.widgets import LocaleText
from src.presentation.tg_bot.states import OrderDetailsSG

from .handlers import extend_order, set_proxy_period

extend_order_window = Window(
    LocaleText("extend-period"),
    Group(
        Button(
            LocaleText("four_hours"),
            id="four_hours",
            on_click=set_proxy_period,
            when=F["order_type"] == "proxy",
        ),
        Button(
            LocaleText("one_day"),
            id="one_day",
            on_click=set_proxy_period,
            when=F["order_type"] != "vpn",
        ),
        Button(
            LocaleText("one_week"),
            id="one_week",
            on_click=set_proxy_period,
            when=F["order_type"] == "proxy",
        ),
        Button(
            LocaleText("two_weeks"),
            id="two_weeks",
            on_click=set_proxy_period,
            when=F["order_type"] != "vpn",
        ),
        Button(
            LocaleText("one_month"),
            id="one_month",
            on_click=set_proxy_period,
        ),
        width=2,
    ),
    Back(LocaleText("back-btn")),
    state=OrderDetailsSG.extend_order,
    # getter=order_info_getter,
)

extend_confirmation_window = Window(
    LocaleText("order-overview"),
    LocaleText("expiring-on", expiring_on="{expiring_on}"),
    LocaleText("extended-expiring-on", extended_expiring_on="{extended_expiring_on}"),
    LocaleText("extend-order-price", extend_price="{extend_price}$"),
    Button(
        LocaleText("confirm-btn"),
        id="confirm_order_button",
        on_click=extend_order,
    ),
    Back(LocaleText("back-btn")),
    state=OrderDetailsSG.extend_confirmation,
    getter=extend_summary_getter,
)
